<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>编辑地址</title>
<jsp:include page="header.jsp"></jsp:include>
</head>
<body ontouchstart>
<!--主体-->
<div class="weui-content">
<form action="/phone/saveAddress" method="post" id="form">
  <div class="weui-cells weui-cells_form wy-address-edit">
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label wy-lab">收货人</label></div>
      <div class="weui-cell__bd"><input class="weui-input" type="text"  placeholder="收货人" name="userName" value="${app.userName}"></div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label wy-lab">手机号</label></div>
      <div class="weui-cell__bd"><input class="weui-input" type="number"  pattern="[0-9]*" placeholder="请输入手机号" name="telephone" value="${app.telephone}"></div>
    </div>
    <!-- <div class="weui-cell">
      <div class="weui-cell__hd"><label for="name" class="weui-label wy-lab">所在地区</label></div>
      <div class="weui-cell__bd"><input class="weui-input" id="address" type="text" value="湖北省 武汉市 武昌区" readonly="" data-code="420106" data-codes="420000,420100,420106"></div>
    </div> -->
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label wy-lab">详细地址</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text"  placeholder="详细地址" name="addressDetail" value="${app.addressDetail}"></div>
      </div>
    </div>
    <div class="weui-cell weui-cell_switch">
      <div class="weui-cell__bd">设为默认地址</div>
      <div class="weui-cell__ft">
      <input class="weui-switch" type="checkbox" checked="checked">
      <input type="hidden" name="state" value="${app.state}"/>
      <input type="hidden" name="id" value="${app.id}"/>
	  <input type="hidden" name="orderId" value="${orderId}"/>
      </div>
    </div>
  </div> 
  <div class="weui-btn-area">
    <a class="weui-btn weui-btn_primary" href="javascript:" id="showTooltips">保存此地址</a>
  </div>
</form>
</div>
<jsp:include page="foot.jsp"></jsp:include>
<script>
      $("#showTooltips").click(function(){
    	if($('.weui-switch').is(":checked")){
    		$('input[name="state"]').val(1);
    	}else{
    		$('input[name="state"]').val(0);
    	}
    	var telephone =$("input[name='telephone']").val();
    	var userName =$("input[name='userName']").val();
    	var addressDetail =$("input[name='addressDetail']").val();
    	var han = /^[\u4e00-\u9fa5]+$/;
    	if(!(/^1[3|4|5|8|7|6][0-9]\d{8}$/.test(telephone))){
    		$.alert("不是完整的11位手机号!");
			return false;
    	}
    	if(!han.test(userName)){
    		$.alert("请输入正确的收货人姓名!");
			return false;
		}
    	if(addressDetail==''){
    		$.alert("请输入正确的收货人地址!");
    		return false;
    	}
    	$('#form').submit();
    	
      });
    </script>
</body>
</html>